package DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import util.JDBCUtil;

import bean.Shop;

public class ShopDao {
	public List<Shop> list() throws Exception{
		//调用jdbcutil方法
		Connection conn = JDBCUtil.getConnection();
		//
		PreparedStatement ps = conn.prepareStatement("select s.*,t.tname from shop s left join type t on s.tid=t.tid");
		//
		ResultSet rs = ps.executeQuery();
		//
		List<Shop> list = new ArrayList<Shop>();
		Shop shop = null;
		while(rs.next()){
			shop = new Shop(rs.getInt("sid"),rs.getString("sname"),rs.getString("sprice"),rs.getDate("time"),rs.getInt("tid"),rs.getString("tname"));
			list.add(shop);
			
		}
		return list;
		
	}
}
